<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>{$meta_title}-狂雨小说CMS</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="__ADMIN__/css/admin.css"></head>
  <link rel="stylesheet" href="__ADMIN__/lib/upload/style.css"></head>
<body>
  <div class="layui-card layui-card-open">
    <div class="layui-card-body">
      <form class="layui-form" action="{:url()}">
        <div class="layui-form-item">
          <label class="layui-form-label">分割字符</label>
          <div class="layui-input-inline">
            <select name="split" lay-filter="split">
              <option value="###">###</option>
              <option value="\r\n\r\n">换行</option>
              <option value="custom">自定义</option>
            </select>
          </div>
        </div>
        <div class="layui-form-item layui-hide" id="zdysplit">
          <label class="layui-form-label">自定义分割字符</label>
          <div class="layui-input-block">
            <input type="text" name="customsplit" class="layui-input" value="">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">小说txt</label>
          <div class="layui-input-block">
            <div class="input-group">
              <input type="text" name="txtpath" style="width:350px;" class="layui-input" value="">
              <div class="layui-btn" id="upload">上传小说</div>
            </div>
          </div>
          <div class="layui-input-block layui-hide"><div id="divFileProgressContainer"></div></div>
        </div>
        <div class="layui-form-item">
          <div class="layui-input-block">
            <input name="novel_id" type="hidden" value="{$Request.param.novel_id}" />
            <input name="id" type="hidden" value="{$Request.param.id}" />
            <button class="layui-btn layui-btn-normal layui-btn-disabled" data-type="tests" lay-filter="import_chapter" type="submit">测试</button>
            <button class="layui-btn layui-btn-disabled" lay-filter="import_chapter" type="submit">提交</button>
          </div>
        </div>
      </form>
    </div>
  </div>
  <script type="text/javascript" src="__STATIC__/jquery/jquery.min.js"></script>
  <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js"></script>
  <script type="text/javascript" src="__ADMIN__/js/admin.js"></script>
  <script type="text/javascript" src="__ADMIN__/lib/upload/md5.js"></script>
  <script type="text/javascript" src="__ADMIN__/lib/upload/webuploader.min.js"></script>
  <script type="text/javascript">var server_url="{:url('upload/sublevel_upload')}",upload_path="txt"</script>
  <script type="text/javascript" src="__ADMIN__/lib/upload/upload.js"></script>
  <script type="text/javascript">
    layui.use(['layer','form'], function(){
      var form = layui.form;
      $('[lay-filter="import_chapter"]').click(function(event) {
        if(!$(this).hasClass('layui-btn-disabled')){
          var query = $("form").find('input,select,textarea').serialize();
          var target = $("form").attr('action');
          var type = $(this).data('type');
          var loadin_layer = layer.msg('解析中',{icon: 16});
          query+="&type="+type;
          $.post(target, query).done(function(data) {
            layer.close(loadin_layer);
              if (data.code == 1) {
                if(type=='tests'){
                  parent.layer.open({type: 1,area: ['600px', '400px'],title:'测试', content: '章节名：'+data.data.title+"<br>章节内容:"+data.data.content});
                }else{
                  layer.msg(data.msg, {icon: 1,time: 2000,shade:0.3},function(){
                    parent.location.reload();
                  });
                }
              } else {
                layer.msg(data.msg,{icon:0})
              }
          });
        }
        return false;
      });
      form.on('select(split)', function(data){
        if(data.value=="custom"){
          $('#zdysplit').removeClass('layui-hide');
        }else{
          $('#zdysplit').addClass('layui-hide');
        }
      });
    });
  </script>
</body>
</html>